<?php

use Illuminate\Support\Facades\Route;


Route::get('/login', [\App\Http\Controllers\admin\LoginController::class, 'index']);
Route::post('/login', [\App\Http\Controllers\admin\LoginController::class, 'login']);

Route::middleware(['admin.auth'])->group(function () {
    Route::post('/logout', [\App\Http\Controllers\admin\LoginController::class, 'logout']);
    Route::post('/ajax/upload', [\App\Http\Controllers\admin\AjaxController::class, 'upload']);
    Route::get('/ajax/getUploadFiles', [\App\Http\Controllers\admin\AjaxController::class, 'getUploadFiles']);

    Route::get('/', function () {
        return view('admin.common.layout', [
            'site_name' => env('app_name', '管理后台'),
            'admin_name' => auth('admin')->user()->username ?? '未知',
        ]);
    });

    Route::get('/home/console', function () { return view('admin.home.console'); });
    Route::get('/home/homepage1', function () { return view('admin.home.homepage1'); });
    Route::get('/home/homepage2', function () { return view('admin.home.homepage2'); });

    Route::get('/curd/index', function () { return view('admin.curd.index'); });
    Route::get('/curd/lists', [\App\Http\Controllers\admin\CurdController::class, 'lists']);
    Route::get('/curd/add', function () { return view('admin.curd.add'); });
    Route::post('/curd/add', [\App\Http\Controllers\admin\CurdController::class, 'add']);

});
